/**
*  \file output.h
*
*  \brief
*
*  \author Michael J. Hohmann  michael.hohmann@linde-mh.de
*
*
*
*
*
*/
#ifndef OUTPUT_H_INCLUDED
#define OUTPUT_H_INCLUDED

/*================================================[ public includes  ]================================================*/
#include "../cfg/prj.h"
#include "../trilean/trilean.h"
#include "../direction_switch/direction_switch.h"
/*================================================[ public defines   ]================================================*/
enum dcLink_state
{
	charging,
	compCharhed,
	discharging
};
/*================================================[ public datatypes ]================================================*/
/** Object definition.
* 
* The struct output_obj defines the attribute of an object.
*/
struct output_data_obj
{   
    BO fan_motor;                         /* X1,23 */
    BO fan_controller;                    /* X1,24:  */
    BO buzzer;                            /*X1,26:    */
    BO alarm_buzzer;
    BO led;
    S16 main_contactor_flag;
    S16 discharge_flag; 
	enum dcLink_state charge_state;
	S16  battery;
	S16  disable_Trac;                   /* disable traction */
	S16  disable_pump;                   /* disable pump     */
    S16 AngPositionSA;
    S16 ChAbsMax;
    S16 H7YP;
    S16 H11R;
    S16 fH1R;
    S16 fH3Y;
    S16 fH8Yl;
    S16 fH5Rl;
    S16 fH13;
    S16 H13_ae;                            /* Signal zur Ansteuerung Lampe, wenn verriegelter Joystick aktiv ist */
    S16 fH16;                              /*boot lid contact open  0*/

    F32 ba_dT_BatFlat_min;                 /* remaining work time (bdi) exceeds limit */
    
    U16 main_contactor_pwm;
    U16 iso_valve_pwm;
     BO precharge;                         /* cpu output */
    S16 pump_motor_rpm;                    /* via can */
    S16 pump_motor_torque;
    BO  pump_motor_discharge;

     BO reset_error_cpu;
     BO dcdc_control;

     BO inverter_1_enable;
     BO inverter_2_enable;


    S16 pwmEnabl;   //pump  PwmEnable
    S16  L_Enable;  //pump  Enable


    U16 vehicle_dtc[4];
    U16 v_debug_0[4];
    U16 v_debug_1[4];
    U16 v_debug_2[4];
    U16 v_debug_3[4];
    U16 v_debug_4[4];
    U16 mLR_CmdHBeatCnt;
    S16 mL_CmdEnable;
    S16 mR_CmdEnable;
     BO mL_CmdPwmEna_1;
     BO mR_CmdPwmEna;
     BO ou_bBlink1_0Hz;
     BO ou_bHourMeter;
     BO fLampH9;
     BO tr_bActive;
    F32 ba_qbat_Disp;                         /* battery charge ratio (bdi) */
    F32 mL_mSet_To_LAC;                       /* units N.M*/
    F32 mR_mSet_To_LAC;                       /* units N.M*/
    F32 ou_tr_vSen;                              /* truck actual speed unit m/s*/
    F32 te_vSen;                              /* truck actual speed unit Km/h*/
     U8 fDiff;        
     BO mL_discharge;
     BO mR_discharge;
    /*  from supervisor */ 
    U8 ou_fRedu1;                             /* from  dsc    speed reduction switch      */ 
    U8 ou_fRedu2;
    U8 ou_fLampYel;                            /* motor over temperature  the  yellow  led on  */
	U8 ou_fLampRed;                            /* motor overtemp. red         */
    U8 ou_fBlinkBrk;
    U8 ou_fDeepDis;                            /* deep-discharge         */
    U8 ou_fLampErr;                            /* error lamp*/  
    U8 ou_fLampBook;                           /* H3 on if DTC present or demanded by application */;  
    U8 ou_fLampH7;
	U8 ou_fBlinkH7;                            /* H7  neutral yellow signal   */ 
    U8 ou_fBlinkSA;                            /* Symbol A  */;  
    

	U8 ou_in_bHBrake_N;                        /* hand brake*/
    enum direction_switch_state ou_direction; 
    S16  ou_park_break_switch;
    U8  ou_seat_switch_1;
	F32 Bat_voltage;                        /* DC_LINK_+_IN_A_CPU_V   */
	S16 trac_temperature;                      /**<   (PT1000, NTC ready)X1,7:  traction_temperature*/
	enum trilean ou_driver_present;               /**<  */
	BO  ou_in_bBelt;;
	S16 ou_te_Angle;
    /* process vars */
//  S16 speed_setpoint;                       /**< speed in mm/s */
//  enum trilean driver_present;              /**<  */
};

/*================================================[ public variables ]================================================*/

/*================================================[ inline functions ]================================================*/

/*================================================[ public functions ]================================================*/
/**
*  Initialization.
*
*  Initialize the output module.
*
*  \return RC_SUCCESS if successful.
*/
RC output_initialize( void );

/** Set outputs
*
*/
void output_set( struct output_data_obj const * p_data );

/**
*  get pointer to current data.
*  This information are may needed for diagnostic reasons and not be used for output control.
*  The data are not threat save.
*
*  return pointer to strut output_data which contains a copy of the last information.
*/
struct output_data_obj const *  output_get_current_data( void );

/*====================================================================================================================*/

#endif

/***********************************************************************************************************************
*                             Copyright 2019 Linde Material Handling. All rights reserved.                             *
***********************************************************************************************************************/
